%option noyywrap nodefault case-insensitive
%{
#ifndef _YACC_TAB_HEADER_
#define _YACC_TAB_HEADER_
#include "y.tab.h"
#endif
%}

%%

create {printf("create\n");return CREATE;}
select {printf("select\n");return SELECT;}
insert {printf("insert\n");return INSERT;}
update {printf("update\n");return INSERT;}
delete {printf("delete\n");return DELETE;}
show {printf("create\n"); return SHOW;}
desc {printf("desc\n"); return DESC;}
databases {printf("create\n");return DATABASES;}
table {printf("table\n");return TABLE;}
into {printf("into\n");return INTO;}
values {printf("values\n");return VALUES;}
where {printf("where\n");return WHERE;}

and {printf("and\n");return AND;}
or {printf("or\n");return OR;}

not {printf("not\n");return NOT;} //  认为与！等价

is {printf("is");return IS;}

null {printf("nul");return NUL;}
!= {yylval.cp = NE; printf("!=\n");return CP;}
> {yylval.cp = GT;  printf(">\n"); return CP;}
\< {yylval.cp = LT; printf("<\n"); return CP;}
>= {yylval.cp = GE; printf(">=\n"); return CP;}
\<= {yylval.cp = LE;printf("<=\n"); return CP;}
== {yylval.cp = EQ; printf("==\n"); return CP;}
! {printf("!\n"); return NOT;}



[+\-]?[1-9][0-9]*|0 {printf("%d|\tas number!\n",atoi(yytext));}
[+\-]?(([1-9][0-9]*)|0)"."[0-9]+  {printf("%lf| as double!\n",atof(yytext));}
[a-zA-Z][a-zA-Z0-9_]+    {printf("%s|\tas Identify!\n",yytext);}
\n {}
[0-9][a-zA-Z0-9_]+ {printf("error:'%s' is not a symbol!\n",yytext);}

; {printf("delimiter\n");}
[ \t] {}
. {printf("%s\n",yytext);}
%%